import { createRouter, createWebHistory } from 'vue-router'


// 定义路由
const routes = [
    
  {
    path: '/user-dashboard',
    name: 'UserDashboard',
    component: () => import('../views/UserDashboard.vue'),
    meta: { requiresAuth: true }
  },
  {
    path: '/manager-dashboard',
    name: 'ManagerDashboard',
    component: () => import('../views/ManagerDashboard.vue'),
    meta: { requiresAuth: true }
  },
  // 兜底路由
  {
    path: '/:pathMatch(.*)*',
    redirect: '/login'
  }
]

// 创建路由实例
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes
})

// 路由守卫示例
router.beforeEach((to, from, next) => {
  console.log(`路由跳转: ${from.path} → ${to.path}`)
  next()
})

export default router